/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.hutech09.jsale.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Nam
 */
@Entity
@NamedQueries({
    @NamedQuery(name = "POrder.findAll", query = "SELECT p FROM POrder p"),
    @NamedQuery(name = "POrder.findById", query = "SELECT p FROM POrder p WHERE p.id = :id"),
    @NamedQuery(name = "POrder.findByCreateDate", query = "SELECT p FROM POrder p WHERE p.createDate = :createDate"),
    @NamedQuery(name = "POrder.findByCustomer", query = "SELECT p FROM POrder p WHERE p.customer = :customer")})
public class POrder implements ICommonEntity, Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Temporal(TemporalType.DATE)
    @JoinColumn(nullable = false)
    private Date createDate;

    @ManyToOne
    @JoinColumn(nullable = false)
    private Customer customer;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof POrder)) {
            return false;
        }
        POrder other = (POrder) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.hutech09.entity.POrder[ id=" + id + " ]";
    }
}
